package com.ruoyi.report_jl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.syrw.annotation.FIllBasicInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.ruoyi.report_jl.domain.bo.ReportJlXjlhnljlbBsInfoBo;
import com.ruoyi.report_jl.domain.vo.ReportJlXjlhnljlbBsInfoVo;
import com.ruoyi.report_jl.domain.ReportJlXjlhnljlbBsInfo;
import com.ruoyi.report_jl.mapper.ReportJlXjlhnljlbBsInfoMapper;
import com.ruoyi.report_jl.service.IReportJlXjlhnljlbBsInfoService;

import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 细含泥量 泥块含量 坚固性记录Service业务层处理
 *
 * @author tll
 * @date 2024-07-31
 */
@RequiredArgsConstructor
@Service
public class ReportJlXjlhnljlbBsInfoServiceImpl implements IReportJlXjlhnljlbBsInfoService {

    private final ReportJlXjlhnljlbBsInfoMapper baseMapper;

    /**
     * 查询细含泥量 泥块含量 坚固性记录
     */
    @Override
    @FIllBasicInfo
    public ReportJlXjlhnljlbBsInfoVo queryById(Long excelId){
        return baseMapper.selectVoById(excelId);
    }

    /**
     * 查询细含泥量 泥块含量 坚固性记录列表
     */
    @Override
    public TableDataInfo<ReportJlXjlhnljlbBsInfoVo> queryPageList(ReportJlXjlhnljlbBsInfoBo bo, PageQuery pageQuery) {
        LambdaQueryWrapper<ReportJlXjlhnljlbBsInfo> lqw = buildQueryWrapper(bo);
        Page<ReportJlXjlhnljlbBsInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
        return TableDataInfo.build(result);
    }

    /**
     * 查询细含泥量 泥块含量 坚固性记录列表
     */
    @Override
    public List<ReportJlXjlhnljlbBsInfoVo> queryList(ReportJlXjlhnljlbBsInfoBo bo) {
        LambdaQueryWrapper<ReportJlXjlhnljlbBsInfo> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<ReportJlXjlhnljlbBsInfo> buildQueryWrapper(ReportJlXjlhnljlbBsInfoBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportJlXjlhnljlbBsInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getTotalPage() != null, ReportJlXjlhnljlbBsInfo::getTotalPage, bo.getTotalPage());
        lqw.eq(bo.getPage() != null, ReportJlXjlhnljlbBsInfo::getPage, bo.getPage());
        lqw.eq(StringUtils.isNotBlank(bo.getJilbh()), ReportJlXjlhnljlbBsInfo::getJilbh, bo.getJilbh());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancdwmc()), ReportJlXjlhnljlbBsInfo::getJiancdwmc, bo.getJiancdwmc());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcbwyt()), ReportJlXjlhnljlbBsInfo::getGongcbwyt, bo.getGongcbwyt());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpmc()), ReportJlXjlhnljlbBsInfo::getYangpmc, bo.getYangpmc());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpbh()), ReportJlXjlhnljlbBsInfo::getYangpbh, bo.getYangpbh());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpsl()), ReportJlXjlhnljlbBsInfo::getYangpsl, bo.getYangpsl());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpzt()), ReportJlXjlhnljlbBsInfo::getYangpzt, bo.getYangpzt());
        lqw.eq(bo.getYangpsj() != null, ReportJlXjlhnljlbBsInfo::getYangpsj, bo.getYangpsj());
        lqw.eq(StringUtils.isNotBlank(bo.getShiyjcrq()), ReportJlXjlhnljlbBsInfo::getShiyjcrq, bo.getShiyjcrq());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjwd()), ReportJlXjlhnljlbBsInfo::getShiytjwd, bo.getShiytjwd());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjsd()), ReportJlXjlhnljlbBsInfo::getShiytjsd, bo.getShiytjsd());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyj()), ReportJlXjlhnljlbBsInfo::getJiancyj, bo.getJiancyj());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyj()), ReportJlXjlhnljlbBsInfo::getPandyj, bo.getPandyj());
        lqw.eq(StringUtils.isNotBlank(bo.getZhuyyqsbmcjbh()), ReportJlXjlhnljlbBsInfo::getZhuyyqsbmcjbh, bo.getZhuyyqsbmcjbh());
        lqw.eq(StringUtils.isNotBlank(bo.getFujsm()), ReportJlXjlhnljlbBsInfo::getFujsm, bo.getFujsm());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobmc()), ReportJlXjlhnljlbBsInfo::getBaobmc, bo.getBaobmc());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobbh()), ReportJlXjlhnljlbBsInfo::getBaobbh, bo.getBaobbh());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcmc()), ReportJlXjlhnljlbBsInfo::getGongcmc, bo.getGongcmc());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancr()), ReportJlXjlhnljlbBsInfo::getJiancr, bo.getJiancr());
        lqw.eq(StringUtils.isNotBlank(bo.getJilr()), ReportJlXjlhnljlbBsInfo::getJilr, bo.getJilr());
        lqw.eq(StringUtils.isNotBlank(bo.getFuhr()), ReportJlXjlhnljlbBsInfo::getFuhr, bo.getFuhr());
        lqw.eq(bo.getRiq() != null, ReportJlXjlhnljlbBsInfo::getRiq, bo.getRiq());
        lqw.eq(StringUtils.isNotBlank(bo.getShebIds()), ReportJlXjlhnljlbBsInfo::getShebIds, bo.getShebIds());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyjIds()), ReportJlXjlhnljlbBsInfo::getJiancyjIds, bo.getJiancyjIds());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyjIds()), ReportJlXjlhnljlbBsInfo::getPandyjIds, bo.getPandyjIds());
        lqw.eq(StringUtils.isNotBlank(bo.getHannlSycs1()), ReportJlXjlhnljlbBsInfo::getHannlSycs1, bo.getHannlSycs1());
        lqw.eq(bo.getHannlM11() != null, ReportJlXjlhnljlbBsInfo::getHannlM11, bo.getHannlM11());
        lqw.eq(bo.getHannlM21() != null, ReportJlXjlhnljlbBsInfo::getHannlM21, bo.getHannlM21());
        lqw.eq(bo.getHannlCz1() != null, ReportJlXjlhnljlbBsInfo::getHannlCz1, bo.getHannlCz1());
        lqw.eq(StringUtils.isNotBlank(bo.getHannlSycs2()), ReportJlXjlhnljlbBsInfo::getHannlSycs2, bo.getHannlSycs2());
        lqw.eq(bo.getHannlM12() != null, ReportJlXjlhnljlbBsInfo::getHannlM12, bo.getHannlM12());
        lqw.eq(bo.getHannlM22() != null, ReportJlXjlhnljlbBsInfo::getHannlM22, bo.getHannlM22());
        lqw.eq(bo.getHannlCz2() != null, ReportJlXjlhnljlbBsInfo::getHannlCz2, bo.getHannlCz2());
        lqw.eq(bo.getHannlPjz() != null, ReportJlXjlhnljlbBsInfo::getHannlPjz, bo.getHannlPjz());
        lqw.eq(StringUtils.isNotBlank(bo.getNikhlSycs1()), ReportJlXjlhnljlbBsInfo::getNikhlSycs1, bo.getNikhlSycs1());
        lqw.eq(bo.getNikhlM01() != null, ReportJlXjlhnljlbBsInfo::getNikhlM01, bo.getNikhlM01());
        lqw.eq(bo.getNikhlM11() != null, ReportJlXjlhnljlbBsInfo::getNikhlM11, bo.getNikhlM11());
        lqw.eq(bo.getNikhlCz1() != null, ReportJlXjlhnljlbBsInfo::getNikhlCz1, bo.getNikhlCz1());
        lqw.eq(StringUtils.isNotBlank(bo.getNikhlSycs2()), ReportJlXjlhnljlbBsInfo::getNikhlSycs2, bo.getNikhlSycs2());
        lqw.eq(bo.getNikhlM02() != null, ReportJlXjlhnljlbBsInfo::getNikhlM02, bo.getNikhlM02());
        lqw.eq(bo.getNikhlM12() != null, ReportJlXjlhnljlbBsInfo::getNikhlM12, bo.getNikhlM12());
        lqw.eq(bo.getNikhlCz2() != null, ReportJlXjlhnljlbBsInfo::getNikhlCz2, bo.getNikhlCz2());
        lqw.eq(bo.getNikhlPjz() != null, ReportJlXjlhnljlbBsInfo::getNikhlPjz, bo.getNikhlPjz());
        lqw.eq(StringUtils.isNotBlank(bo.getJiangxPzsj()), ReportJlXjlhnljlbBsInfo::getJiangxPzsj, bo.getJiangxPzsj());
        lqw.eq(bo.getJiangxWd() != null, ReportJlXjlhnljlbBsInfo::getJiangxWd, bo.getJiangxWd());
        lqw.eq(bo.getJiangxXdmd() != null, ReportJlXjlhnljlbBsInfo::getJiangxXdmd, bo.getJiangxXdmd());
        lqw.eq(StringUtils.isNotBlank(bo.getJiangxGclj1()), ReportJlXjlhnljlbBsInfo::getJiangxGclj1, bo.getJiangxGclj1());
        lqw.eq(bo.getJiangxMi1() != null, ReportJlXjlhnljlbBsInfo::getJiangxMi1, bo.getJiangxMi1());
        lqw.eq(bo.getJiangxC11() != null, ReportJlXjlhnljlbBsInfo::getJiangxC11, bo.getJiangxC11());
        lqw.eq(bo.getJiangxC21() != null, ReportJlXjlhnljlbBsInfo::getJiangxC21, bo.getJiangxC21());
        lqw.eq(bo.getJiangxC31() != null, ReportJlXjlhnljlbBsInfo::getJiangxC31, bo.getJiangxC31());
        lqw.eq(bo.getJiangxSsbfl1() != null, ReportJlXjlhnljlbBsInfo::getJiangxSsbfl1, bo.getJiangxSsbfl1());
        lqw.eq(bo.getJiangxFjzl1() != null, ReportJlXjlhnljlbBsInfo::getJiangxFjzl1, bo.getJiangxFjzl1());
        lqw.eq(StringUtils.isNotBlank(bo.getJiangxGclj2()), ReportJlXjlhnljlbBsInfo::getJiangxGclj2, bo.getJiangxGclj2());
        lqw.eq(bo.getJiangxMi2() != null, ReportJlXjlhnljlbBsInfo::getJiangxMi2, bo.getJiangxMi2());
        lqw.eq(bo.getJiangxC12() != null, ReportJlXjlhnljlbBsInfo::getJiangxC12, bo.getJiangxC12());
        lqw.eq(bo.getJiangxC22() != null, ReportJlXjlhnljlbBsInfo::getJiangxC22, bo.getJiangxC22());
        lqw.eq(bo.getJiangxC32() != null, ReportJlXjlhnljlbBsInfo::getJiangxC32, bo.getJiangxC32());
        lqw.eq(bo.getJiangxSsbfl2() != null, ReportJlXjlhnljlbBsInfo::getJiangxSsbfl2, bo.getJiangxSsbfl2());
        lqw.eq(bo.getJiangxFjzl2() != null, ReportJlXjlhnljlbBsInfo::getJiangxFjzl2, bo.getJiangxFjzl2());
        lqw.eq(StringUtils.isNotBlank(bo.getJiangxGclj3()), ReportJlXjlhnljlbBsInfo::getJiangxGclj3, bo.getJiangxGclj3());
        lqw.eq(bo.getJiangxMi3() != null, ReportJlXjlhnljlbBsInfo::getJiangxMi3, bo.getJiangxMi3());
        lqw.eq(bo.getJiangxC13() != null, ReportJlXjlhnljlbBsInfo::getJiangxC13, bo.getJiangxC13());
        lqw.eq(bo.getJiangxC23() != null, ReportJlXjlhnljlbBsInfo::getJiangxC23, bo.getJiangxC23());
        lqw.eq(bo.getJiangxC33() != null, ReportJlXjlhnljlbBsInfo::getJiangxC33, bo.getJiangxC33());
        lqw.eq(bo.getJiangxSsbfl3() != null, ReportJlXjlhnljlbBsInfo::getJiangxSsbfl3, bo.getJiangxSsbfl3());
        lqw.eq(bo.getJiangxFjzl3() != null, ReportJlXjlhnljlbBsInfo::getJiangxFjzl3, bo.getJiangxFjzl3());
        lqw.eq(StringUtils.isNotBlank(bo.getJiangxGclj4()), ReportJlXjlhnljlbBsInfo::getJiangxGclj4, bo.getJiangxGclj4());
        lqw.eq(bo.getJiangxMi4() != null, ReportJlXjlhnljlbBsInfo::getJiangxMi4, bo.getJiangxMi4());
        lqw.eq(bo.getJiangxC14() != null, ReportJlXjlhnljlbBsInfo::getJiangxC14, bo.getJiangxC14());
        lqw.eq(bo.getJiangxC24() != null, ReportJlXjlhnljlbBsInfo::getJiangxC24, bo.getJiangxC24());
        lqw.eq(bo.getJiangxC34() != null, ReportJlXjlhnljlbBsInfo::getJiangxC34, bo.getJiangxC34());
        lqw.eq(bo.getJiangxSsbfl4() != null, ReportJlXjlhnljlbBsInfo::getJiangxSsbfl4, bo.getJiangxSsbfl4());
        lqw.eq(bo.getJiangxFjzl4() != null, ReportJlXjlhnljlbBsInfo::getJiangxFjzl4, bo.getJiangxFjzl4());
        lqw.eq(bo.getJiangxPjz() != null, ReportJlXjlhnljlbBsInfo::getJiangxPjz, bo.getJiangxPjz());
        return lqw;
    }

    /**
     * 新增细含泥量 泥块含量 坚固性记录
     */
    @Override
    public Boolean insertByBo(ReportJlXjlhnljlbBsInfoBo bo) {
        ReportJlXjlhnljlbBsInfo add = BeanUtil.toBean(bo, ReportJlXjlhnljlbBsInfo.class);
        validEntityBeforeSave(add);
        boolean flag = baseMapper.insert(add) > 0;
        if (flag) {
            bo.setExcelId(add.getExcelId());
        }
        return flag;
    }

    /**
     * 修改细含泥量 泥块含量 坚固性记录
     */
    @Override
    public Boolean updateByBo(ReportJlXjlhnljlbBsInfoBo bo) {
        ReportJlXjlhnljlbBsInfo update = BeanUtil.toBean(bo, ReportJlXjlhnljlbBsInfo.class);
        validEntityBeforeSave(update);
        return baseMapper.updateById(update) > 0;
    }

    /**
     * 保存前的数据校验
     */
    private void validEntityBeforeSave(ReportJlXjlhnljlbBsInfo entity){
        //TODO 做一些数据校验,如唯一约束
    }

    /**
     * 批量删除细含泥量 泥块含量 坚固性记录
     */
    @Override
    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
        if(isValid){
            //TODO 做一些业务上的校验,判断是否需要校验
        }
        return baseMapper.deleteBatchIds(ids) > 0;
    }
}
